package com.xyzh05.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;

@Entity
@Table(name="editor")
@Searchable
@XmlRootElement
public class Editor extends BaseObject implements Serializable {
	private static final long serialVersionUID = -5753174150494805650L;
	
	private Long id;
    private Long school;
    private Long region;
    private Long major;
    private Long formerDegree;
    private Long degree;
    private Long entrolyear;
    private Long graduateyear;
    private String collegeEmail;
    private Long grade;
    private Long nice;
    private Long volume;
    private Double praise;
    private Long idle;
    private Long remainIdle;
    private Long servicetype;
    private String resume;
    private String personalSignature;
    private Long referrerid;
    private String paypalno;
    private Long formermajor;
    private Long edType;
    private Long edServedService;
    private Long edAppliedService;
    private Long edCapableService;
    private String edResumePath;
    private String edResumeName;
    private User user ;
    
    
    
    @OneToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="userid", nullable=false)
    public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Id @GeneratedValue(strategy=GenerationType.AUTO) @SearchableId    
    public Long getId() {
        return this.id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    @Column(name="school", nullable=false)
    @SearchableProperty
    public Long getSchool() {
        return this.school;
    }
    
    public void setSchool(Long school) {
        this.school = school;
    }
    
    @Column(name="region", nullable=false)
    @SearchableProperty
    public Long getRegion() {
        return this.region;
    }
    
    public void setRegion(Long region) {
        this.region = region;
    }
    
    @Column(name="major", nullable=false)
    @SearchableProperty
    public Long getMajor() {
        return this.major;
    }
    
    public void setMajor(Long major) {
        this.major = major;
    }
    
    @Column(name="formerDegree", nullable=false)
    @SearchableProperty
    public Long getFormerDegree() {
        return this.formerDegree;
    }
    
    public void setFormerDegree(Long formerDegree) {
        this.formerDegree = formerDegree;
    }
    
    @Column(name="degree", nullable=false)
    @SearchableProperty
    public Long getDegree() {
        return this.degree;
    }
    
    public void setDegree(Long degree) {
        this.degree = degree;
    }
    
    @Column(name="entrolyear", nullable=false)
    @SearchableProperty
    public Long getEntrolyear() {
        return this.entrolyear;
    }
    
    public void setEntrolyear(Long entrolyear) {
        this.entrolyear = entrolyear;
    }
    
    @Column(name="graduateyear", nullable=false)
    @SearchableProperty
    public Long getGraduateyear() {
        return this.graduateyear;
    }
    
    public void setGraduateyear(Long graduateyear) {
        this.graduateyear = graduateyear;
    }
    
    @Column(name="collegeEmail", nullable=false)
    @SearchableProperty
    public String getCollegeEmail() {
        return this.collegeEmail;
    }
    
    public void setCollegeEmail(String collegeEmail) {
        this.collegeEmail = collegeEmail;
    }
    
    @Column(name="grade", nullable=false)
    @SearchableProperty
    public Long getGrade() {
        return this.grade;
    }
    
    public void setGrade(Long grade) {
        this.grade = grade;
    }
    
    @Column(name="nice", nullable=false)
    @SearchableProperty
    public Long getNice() {
        return this.nice;
    }
    
    public void setNice(Long nice) {
        this.nice = nice;
    }
    
    @Column(name="volume", nullable=false)
    @SearchableProperty
    public Long getVolume() {
        return this.volume;
    }
    
    public void setVolume(Long volume) {
        this.volume = volume;
    }
    
    @Column(name="praise", nullable=false, precision=22, scale=0)
    @SearchableProperty
    public Double getPraise() {
        return this.praise;
    }
    
    public void setPraise(Double praise) {
        this.praise = praise;
    }
    
    @Column(name="idle", nullable=false)
    @SearchableProperty
    public Long getIdle() {
        return this.idle;
    }
    
    public void setIdle(Long idle) {
        this.idle = idle;
    }
    
    @Column(name="remainidle", nullable=false)
    @SearchableProperty
    public Long getRemainIdle() {
        return this.remainIdle;
    }
    
    public void setRemainIdle(Long remainidle) {
        this.remainIdle = remainidle;
    }
    
    @Column(name="servicetype", nullable=false)
    @SearchableProperty
    public Long getServicetype() {
        return this.servicetype;
    }
    
    public void setServicetype(Long servicetype) {
        this.servicetype = servicetype;
    }
    
    @Column(name="resume", length=65535)
    @SearchableProperty
    public String getResume() {
        return this.resume;
    }
    
    public void setResume(String resume) {
        this.resume = resume;
    }
    
    @Column(name="personalSignature", length=65535)
    @SearchableProperty
    public String getPersonalSignature() {
        return this.personalSignature;
    }
    
    public void setPersonalSignature(String personalSignature) {
        this.personalSignature = personalSignature;
    }
    
    @Column(name="referrerid")
    @SearchableProperty
    public Long getReferrerid() {
        return this.referrerid;
    }
    
    public void setReferrerid(Long referrerid) {
        this.referrerid = referrerid;
    }
    
    @Column(name="paypalno")
    @SearchableProperty
    public String getPaypalno() {
        return this.paypalno;
    }
    
    public void setPaypalno(String paypalno) {
        this.paypalno = paypalno;
    }
    
    @Column(name="formermajor", nullable=false)
    @SearchableProperty
    public Long getFormermajor() {
        return this.formermajor;
    }
    
    public void setFormermajor(Long formermajor) {
        this.formermajor = formermajor;
    }
    
    @Column(name="ed_type")
    @SearchableProperty
    public Long getEdType() {
        return this.edType;
    }
    
    public void setEdType(Long edType) {
        this.edType = edType;
    }
    
    @Column(name="ed_served_service")
    @SearchableProperty
    public Long getEdServedService() {
        return this.edServedService;
    }
    
    public void setEdServedService(Long edServedService) {
        this.edServedService = edServedService;
    }
    
    @Column(name="ed_applied_service")
    @SearchableProperty
    public Long getEdAppliedService() {
        return this.edAppliedService;
    }
    
    public void setEdAppliedService(Long edAppliedService) {
        this.edAppliedService = edAppliedService;
    }
    
    @Column(name="ed_capable_service")
    @SearchableProperty
    public Long getEdCapableService() {
        return this.edCapableService;
    }
    
    public void setEdCapableService(Long edCapableService) {
        this.edCapableService = edCapableService;
    }
    
    @Column(name="ed_resume_path")
    @SearchableProperty
    public String getEdResumePath() {
        return this.edResumePath;
    }
    
    public void setEdResumePath(String edResumePath) {
        this.edResumePath = edResumePath;
    }
    
    @Column(name="ed_resume_name")
    @SearchableProperty
    public String getEdResumeName() {
        return this.edResumeName;
    }
    
    public void setEdResumeName(String edResumeName) {
        this.edResumeName = edResumeName;
    }

    
    public boolean isServed(ServiceType serviceType) {
		return (this.edServedService & serviceType.getStBinary()) != 0;
	}
    
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Editor pojo = (Editor) o;

        if (user != null ? !user.equals(pojo.user) : pojo.user != null) return false;
        if (school != null ? !school.equals(pojo.school) : pojo.school != null) return false;
        if (region != null ? !region.equals(pojo.region) : pojo.region != null) return false;
        if (major != null ? !major.equals(pojo.major) : pojo.major != null) return false;
        if (formerDegree != null ? !formerDegree.equals(pojo.formerDegree) : pojo.formerDegree != null) return false;
        if (degree != null ? !degree.equals(pojo.degree) : pojo.degree != null) return false;
        if (entrolyear != null ? !entrolyear.equals(pojo.entrolyear) : pojo.entrolyear != null) return false;
        if (graduateyear != null ? !graduateyear.equals(pojo.graduateyear) : pojo.graduateyear != null) return false;
        if (collegeEmail != null ? !collegeEmail.equals(pojo.collegeEmail) : pojo.collegeEmail != null) return false;
        if (grade != null ? !grade.equals(pojo.grade) : pojo.grade != null) return false;
        if (nice != null ? !nice.equals(pojo.nice) : pojo.nice != null) return false;
        if (volume != null ? !volume.equals(pojo.volume) : pojo.volume != null) return false;
        if (praise != null ? !praise.equals(pojo.praise) : pojo.praise != null) return false;
        if (idle != null ? !idle.equals(pojo.idle) : pojo.idle != null) return false;
        if (remainIdle != null ? !remainIdle.equals(pojo.remainIdle) : pojo.remainIdle != null) return false;
        if (servicetype != null ? !servicetype.equals(pojo.servicetype) : pojo.servicetype != null) return false;
        if (resume != null ? !resume.equals(pojo.resume) : pojo.resume != null) return false;
        if (personalSignature != null ? !personalSignature.equals(pojo.personalSignature) : pojo.personalSignature != null) return false;
        if (referrerid != null ? !referrerid.equals(pojo.referrerid) : pojo.referrerid != null) return false;
        if (paypalno != null ? !paypalno.equals(pojo.paypalno) : pojo.paypalno != null) return false;
        if (formermajor != null ? !formermajor.equals(pojo.formermajor) : pojo.formermajor != null) return false;
        if (edType != null ? !edType.equals(pojo.edType) : pojo.edType != null) return false;
        if (edServedService != null ? !edServedService.equals(pojo.edServedService) : pojo.edServedService != null) return false;
        if (edAppliedService != null ? !edAppliedService.equals(pojo.edAppliedService) : pojo.edAppliedService != null) return false;
        if (edCapableService != null ? !edCapableService.equals(pojo.edCapableService) : pojo.edCapableService != null) return false;
        if (edResumePath != null ? !edResumePath.equals(pojo.edResumePath) : pojo.edResumePath != null) return false;
        if (edResumeName != null ? !edResumeName.equals(pojo.edResumeName) : pojo.edResumeName != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (user != null ? user.hashCode() : 0);
        result = 31 * result + (school != null ? school.hashCode() : 0);
        result = 31 * result + (region != null ? region.hashCode() : 0);
        result = 31 * result + (major != null ? major.hashCode() : 0);
        result = 31 * result + (formerDegree != null ? formerDegree.hashCode() : 0);
        result = 31 * result + (degree != null ? degree.hashCode() : 0);
        result = 31 * result + (entrolyear != null ? entrolyear.hashCode() : 0);
        result = 31 * result + (graduateyear != null ? graduateyear.hashCode() : 0);
        result = 31 * result + (collegeEmail != null ? collegeEmail.hashCode() : 0);
        result = 31 * result + (grade != null ? grade.hashCode() : 0);
        result = 31 * result + (nice != null ? nice.hashCode() : 0);
        result = 31 * result + (volume != null ? volume.hashCode() : 0);
        result = 31 * result + (praise != null ? praise.hashCode() : 0);
        result = 31 * result + (idle != null ? idle.hashCode() : 0);
        result = 31 * result + (remainIdle != null ? remainIdle.hashCode() : 0);
        result = 31 * result + (servicetype != null ? servicetype.hashCode() : 0);
        result = 31 * result + (resume != null ? resume.hashCode() : 0);
        result = 31 * result + (personalSignature != null ? personalSignature.hashCode() : 0);
        result = 31 * result + (referrerid != null ? referrerid.hashCode() : 0);
        result = 31 * result + (paypalno != null ? paypalno.hashCode() : 0);
        result = 31 * result + (formermajor != null ? formermajor.hashCode() : 0);
        result = 31 * result + (edType != null ? edType.hashCode() : 0);
        result = 31 * result + (edServedService != null ? edServedService.hashCode() : 0);
        result = 31 * result + (edAppliedService != null ? edAppliedService.hashCode() : 0);
        result = 31 * result + (edCapableService != null ? edCapableService.hashCode() : 0);
        result = 31 * result + (edResumePath != null ? edResumePath.hashCode() : 0);
        result = 31 * result + (edResumeName != null ? edResumeName.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("id").append("='").append(getId()).append("', ");
        sb.append("user").append("='").append(getUser()).append("', ");
        sb.append("school").append("='").append(getSchool()).append("', ");
        sb.append("region").append("='").append(getRegion()).append("', ");
        sb.append("major").append("='").append(getMajor()).append("', ");
        sb.append("formerDegree").append("='").append(getFormerDegree()).append("', ");
        sb.append("degree").append("='").append(getDegree()).append("', ");
        sb.append("entrolyear").append("='").append(getEntrolyear()).append("', ");
        sb.append("graduateyear").append("='").append(getGraduateyear()).append("', ");
        sb.append("collegeEmail").append("='").append(getCollegeEmail()).append("', ");
        sb.append("grade").append("='").append(getGrade()).append("', ");
        sb.append("nice").append("='").append(getNice()).append("', ");
        sb.append("volume").append("='").append(getVolume()).append("', ");
        sb.append("praise").append("='").append(getPraise()).append("', ");
        sb.append("idle").append("='").append(getIdle()).append("', ");
        sb.append("remainidle").append("='").append(getRemainIdle()).append("', ");
        sb.append("servicetype").append("='").append(getServicetype()).append("', ");
        sb.append("resume").append("='").append(getResume()).append("', ");
        sb.append("personalSignature").append("='").append(getPersonalSignature()).append("', ");
        sb.append("referrerid").append("='").append(getReferrerid()).append("', ");
        sb.append("paypalno").append("='").append(getPaypalno()).append("', ");
        sb.append("formermajor").append("='").append(getFormermajor()).append("', ");
        sb.append("edType").append("='").append(getEdType()).append("', ");
        sb.append("edServedService").append("='").append(getEdServedService()).append("', ");
        sb.append("edAppliedService").append("='").append(getEdAppliedService()).append("', ");
        sb.append("edCapableService").append("='").append(getEdCapableService()).append("', ");
        sb.append("edResumePath").append("='").append(getEdResumePath()).append("', ");
        sb.append("edResumeName").append("='").append(getEdResumeName()).append("'");
        sb.append("]");
      
        return sb.toString();
    }

}
